/**
 *	人员管理
 *	@auth liangpingzheng
 *	@date 2018-02-27
 */
layui.use(['form', 'layer', 'laydate', 'table', 'laytpl'], function () {

    //声明变量
    var layer = parent.layer === undefined ? layui.layer : top.layer
            , table = layui.table
            , form = layui.form
            , layedit = layui.layedit
            , laydate = layui.laydate
            , laytpl = layui.laytpl
            , $ = layui.$;

    /**
     * 单选模板封装
     */
    var switchTpl = function (field, text) {
        var strHtml = '{{#  if(d.' + field + ' == "1" || d.' + field + ' == true){ }}'
                + '<input type="checkbox" name="' + field + '" value="{{d.' + field + '}}" lay-skin="switch" lay-text="' + text + '" lay-filter="switch" checked>'
                + '{{#  } else { }}'
                + '<input type="checkbox" name="' + field + '" value="{{d.' + field + '}}" lay-skin="switch" lay-text="' + text + '" lay-filter="switch">'
                + '{{#  } }}';

        return '<div>' + strHtml + '</div>';
    }

    //调用API接口渲染TABLE(方法级)
    var tableIns = table.render({
        elem: "#tableList"
        , url: "/manager/icon"
        , method: 'post'
        , cellMinWidth: 100
//		,page : true
        , page: {
            layout: ['limit', 'count', 'prev', 'page', 'next', 'skip'] //自定义分页布局
                    // 限定条数   总数、计数  上一页     页     下一页    到第几页、跳
            , curr: 1
            , groups: 10 //显示 连续页码
            , first: '首页'
            , last: '尾页'
        }
        , height: "full-125"
        , limit: 20
        , limits: [20, 30, 40, 50, 60, 70, 80, 90, 100, 150, 200]
        , even: true //开启隔行背景
        , cols: [[
                {field: 'id', width: "10%", title: 'ID', align: 'center', sort: true, fixed: 'left'}

                , {field: 'icon', width: "10%", title: '类名', align: 'center'}

                , {field: 'icon', width: "30%", title: '图标', align: 'center', templet: function (data) {
                        return '<i class="larry-icon ' + data.icon + '" data-icon="' + data.icon + '" data-font="larry-icon"></i>';
                    }
                }
            ]]
    });

    //搜索功能
    $(".search_btn").on("click", function () {
        if ($(".searchVal").val() != '') {
            table.reload("tableList", {
                page: {
                    curr: 1 //重新从第 1 页开始
                },
                where: {
                    keyword: $(".searchVal").val()  //搜索的关键字
                }
            })
        } else {
            layer.msg("请输入搜索的内容");
        }
    });






});